package com.example.librarymanagersystem.service.impl;

import com.example.librarymanagersystem.dao.BookInfoMapper;
import com.example.librarymanagersystem.entity.BookInfo;
import com.example.librarymanagersystem.service.BookInfoServie;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookInfoServieImpl implements BookInfoServie {

    @Autowired
    private BookInfoMapper bookInfoMapper;

    @Override
    public PageInfo<BookInfo> findAll(int pageNo, int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<BookInfo> bookInfos = bookInfoMapper.selectAll();
        PageInfo<BookInfo> page = new PageInfo<>(bookInfos);
        return page;
    }

    @Override
    public PageInfo<BookInfo> findBykeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        List<BookInfo> bookInfos = bookInfoMapper.selectByword(keyword);
        PageInfo<BookInfo> page = new PageInfo<>(bookInfos);
        return page;
    }
}
